package com.groupbuying.storeinternal.utils.apiresult;

/**
 * @Author: wenguoqiang
 * @Email wguoqiango@163.com
 * @Date: 2020/1/10 0010 下午 3:52
 * @Des
 */
public class AppApiResult extends ApiResult{

    /**
     * 编码
     */
    private static final String RETURN_CODE = "return_code";

    private static final Integer APP_REQUEST_SECCESS_CODE = 0;

    private static final Integer APP_REQUEST_FAIL_CODE = 1;

    public static ApiResult success() {
        ApiResult apiResult = ApiResult.success();
        apiResult.put(RETURN_CODE,APP_REQUEST_SECCESS_CODE);
        return apiResult;
   }

    public static ApiResult success(Object resultData) {
        ApiResult result = ApiResult.success(resultData);
        result.put(RETURN_CODE,APP_REQUEST_SECCESS_CODE);
        return result;
    }

    public static ApiResult success(Integer code, String msg) {
        ApiResult result = ApiResult.success(code,msg);
        result.put(RETURN_CODE,APP_REQUEST_SECCESS_CODE);
        return result;
    }

    public static ApiResult success(ApiResultCode apiResultCode, Object resultData) {
        ApiResult result = ApiResult.success(apiResultCode,resultData);
        result.put(RETURN_CODE,APP_REQUEST_SECCESS_CODE);
        return result;
    }

    public static ApiResult failure() {
        ApiResult result =  ApiResult.failure();
        result.put(RETURN_CODE,APP_REQUEST_FAIL_CODE);
        return result;
    }

    public static ApiResult failure(Object resultData) {
        ApiResult result = ApiResult.failure(resultData);
        result.put(RETURN_CODE,APP_REQUEST_FAIL_CODE);
        return result;
    }

    public static ApiResult failure(ApiResultCode apiResultCode, Object resultData) {
        ApiResult result = ApiResult.failure(apiResultCode,resultData);
        result.put(RETURN_CODE,APP_REQUEST_FAIL_CODE);
        return result;
    }

    public static ApiResult failure(Integer code, String message) {
        ApiResult result =  ApiResult.failure(code,message);
        result.put(RETURN_CODE,APP_REQUEST_FAIL_CODE);
        return result;
    }

    public static ApiResult failure(Integer code, String message, Object resultData) {
        ApiResult result =ApiResult.failure(code,message,resultData);
        result.put(RETURN_CODE,APP_REQUEST_FAIL_CODE);
        return result;
    }

    public static ApiResult operateSuccess() {
        ApiResult result = ApiResult.operateSuccess();
        result.put(RETURN_CODE,APP_REQUEST_SECCESS_CODE);
        return result;
    }

    //检测参数为空
    public static ApiResult paramIsNull(){
        ApiResult result = ApiResult.paramIsNull();
        result.put(RETURN_CODE,APP_REQUEST_FAIL_CODE);
        return result;
    }


}
